#!/usr/bin/python3
# -*- coding: utf-8 -*-

import os
import sys
import argparse

from module import evaluation

EVALUATION_VERSION = "v1.2.0"


def parse_args():
    parser = argparse.ArgumentParser(description="Precision Calculation Include COCO and Task Precision")
    parser.add_argument("--categories-file", 
                        type=str, 
                        default='data/categories.json',
                        required=False,
                        help="categories name coco format")
    parser.add_argument("--imageset", 
                        default="data/test.json",
                        type=str, 
                        required=False,
                        help="coco format anno list")
    parser.add_argument("--annotations-folder", 
                        default="data/xml",
                        type=str, 
                        required=False,
                        help="voc format anno list")
    parser.add_argument("--detection-file", 
                        default="data/result/result.json",
                        type=str, 
                        required=False,
                        help="detections output file or folder, support task xml")
    parser.add_argument("--images-folder", 
                        default=None, 
                        type=str,
                        help="images folder")
    parser.add_argument("--output-folder", 
                        type=str, 
                        default=None,
                        help="directory for saving output")
    args = parser.parse_args()
    print(args)
        
    if args.output_folder:
        if not args.images_folder:
            print("find invalid image folder path, forbidden output image")
            args.output_folder = None

    return args

if __name__ == '__main__':
    args = parse_args()
    precision = evaluation.Precisoin(args)
    precision.load_data()
    precision.get_precision()